#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <stdlib.h>
using namespace std;
typedef struct node{
    int value;
    node *left;
    node *right;
}node;

bool _Vaild(node* root,int lower,int upper)
{
    if(!root)
        return true;
    if(root->value<=lower||root->value>=upper)
        return false;//不符合范围要求
    return _Vaild(root->left,lower,root->value)&&_Vaild(root->right,root->value,upper);//左子树要小所以更新最大值，右子树要大所以更新最小值
}

bool isValidBST(node* root){
    return _Vaild(root,-2147483648,2147483647);//这里是根结点，不限制范围
}

int main(){
    vector<string> a;
    
    char c;
    string ch="";
    while ((c=getchar())){
        if (c!=' '&&c!='\n'){
            ch+=c; 
        }
        else{
            a.push_back(ch);
            ch.clear();
            
    
        }
        if (c=='\n'){
            break;
        }
    }
    
    
    //printf("!");
    /*for (int i=0; i<a.size(); i++){
        printf("%s ",a[i].c_str());
    }*/
    int index=0;
    if (a[0]=="null"){
        cout<<true<<endl;
        return 0;
    }
    queue<node *>nodes;
    node *root=(node *)malloc(sizeof(node));
    root->left=NULL;
    root->right=NULL;
    root->value=stoi(a[index]);

    //cout<<stoi(a[index]);

    index++;
    nodes.push(root);
    while (nodes.size()&&index<a.size()){
        node *current=nodes.front();
        nodes.pop();
        
        if (a[index]!="null"){
            node *child=(node *)malloc(sizeof(node));
            child->left=NULL;
            child->right=NULL;

            //cout<<"?"<<a[index]<<"?"<<endl;

            child->value=stoi(a[index]);
            current->left=child;
            nodes.push(child);
        }
        index++;
        //cout<<a[index]<<endl;

        if (a[index]!="null"&&index<a.size()){
            node *child=(node *)malloc(sizeof(node));
            child->left=NULL;
            child->right=NULL;

            //cout<<"?"<<a[index]<<"?"<<endl;

            child->value=stoi(a[index]);
            current->right=child;
            nodes.push(child);
        }
        index++;

        
    }
    if (isValidBST(root)){
        printf("true");
    }
    else printf("false");

    return 0;
}